<?php
defined('_XR_EXEC') or die();
/**
 * 具体某个会员的配送 
 */
class send_Model extends Model
{ 
	
	public static function isbyself($send_id){
		static $instance = array();
		if (!isset($instance[$send_id])) {
			$instance[$send_id] = self::isbyself_do($send_id);
		}
		return $instance[$send_id];
	}
	public function isbyself_do($send_id){
		$ret = false;
		$arr1 = array();
		$arr2 = array();
		$db = factory::getdbo();
		$rs_send = $db->loadassoc('select * from t_send where id="'.$send_id.'" ');
		if(!$rs_send){
			return false;
		}
		$rs_send_vege = $db->loadassoclist('
			select 
				a.vege_id,
				a.vege_num
			from t_send_vege a 
			where a.send_id="'.$send_id.'" and a.fixed=0 
		');
		if(count($rs_send_vege) == 0){
			return false;
		}
		foreach($rs_send_vege as $v){
			$arr1[$v['vege_id'].'-'.$v['vege_num']] = $v['vege_id'].'-'.$v['vege_num'];
		}
		$rs_sendfen = $db->loadassoc('select * from t_sendfen where id="'.$rs_send['sendfen_id'].'" ');
		if(!$rs_send){
			return false;
		}
		$rs_sendfen_vege = $db->loadassoclist('
			select 
				a.vege_id,
				a.vege_num
			from t_sendfen_vege a 
			where a.sendfen_id="'.$rs_sendfen['id'].'" and a.fixed=0 
		');
		if(count($rs_sendfen_vege) == 0){
			return false;
		}
		foreach($rs_sendfen_vege as $v){
			$arr2[$v['vege_id'].'-'.$v['vege_num']] = $v['vege_id'].'-'.$v['vege_num'];
		}
		foreach($arr1 as $v){
			if(!isset($arr2[$v])){
				$ret = true;
				break;
			}
		}
		return $ret; 
	}
 
	
	
	
	
}

?>